#include "mod_priv.h"

/* Graphic module. */
#define APPLE_MODULE_NAME	"grah"

void *grah_main_window_init(int argc, char *argv[])
{
	GtkWidget *window;

	gtk_init(&argc, &argv);
	
	window = build_main_window();
	return window;
}

static int grah_init(apple_module_t *m)
{
	printf("grah_init.\n");
	m->priv = grah_main_window_init(0, NULL);

	return 0;
}

static int grah_start(apple_module_t *m)
{	
	printf("grah_start.\n");
	assert(m && m->priv);

	gtk_widget_show_all((GtkWidget *)m->priv);
	gtk_main();

	return 0;
}

apple_module_t mod_grah = {
	APPLE_MODULE_NAME,
	APPLE_MODULE_TYPE_DICT,
	grah_init,
	NULL,
	grah_start,	/* gtk_main_quit will be called by close window callback. 
			 * we do not need care for it. */
};

int module_grah_init(void)
{
	return register_apple_module(&mod_grah);
}

void module_grah_exit(void)
{
	unregister_apple_module(&mod_grah);
}
